package com.swe.chums.dao.example;

import java.math.*;
import java.util.Date;
import java.util.List;
import com.swe.chums.dao.FeedbackDao;
import com.swe.chums.dao.model.Feedback;
import com.swe.chums.dao.exceptions.FeedbackDaoException;
import com.swe.chums.dao.factory.DaoFactory;

public class FeedbackDaoExample
{
	/**
	 * Method 'main'
	 * 
	 * @param arg
	 * @throws Exception
	 */
	public static void main(String[] arg) throws Exception
	{
		// Uncomment one of the lines below to test the generated code
		
		// findAll();
		// findByUser(0);
		// findWhereIdEquals(0);
		// findWhereUserIDEquals(0);
		// findWhereTextEquals(0);
		// findWhereDateEquals(null);
		// findWhereProcessedEquals(0);
	}

	/**
	 * Method 'findAll'
	 * 
	 * @throws Exception
	 */
	public static void findAll() throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findAll();
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findByUser'
	 * 
	 * @param userID
	 * @throws Exception
	 */
	public static void findByUser(int userID) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findByUser(userID);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereIdEquals'
	 * 
	 * @param id
	 * @throws Exception
	 */
	public static void findWhereIdEquals(int id) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findWhereIdEquals(id);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereUserIDEquals'
	 * 
	 * @param userID
	 * @throws Exception
	 */
	public static void findWhereUserIDEquals(int userID) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findWhereUserIDEquals(userID);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereTextEquals'
	 * 
	 * @param text
	 * @throws Exception
	 */
	public static void findWhereTextEquals(String text) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findWhereTextEquals(text);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereDateEquals'
	 * 
	 * @param date
	 * @throws Exception
	 */
	public static void findWhereDateEquals(Date date) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findWhereDateEquals(date);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'findWhereProcessedEquals'
	 * 
	 * @param processed
	 * @throws Exception
	 */
	public static void findWhereProcessedEquals(int processed) throws Exception
	{
		FeedbackDao dao = DaoFactory.createFeedbackDao();
		List<Feedback> _result = dao.findWhereProcessedEquals(processed);
		for (Feedback dto : _result) {
			display(dto);
		}
		
	}

	/**
	 * Method 'display'
	 * 
	 * @param dto
	 */
	public static void display(Feedback dto)
	{
		StringBuffer buf = new StringBuffer();
		buf.append( dto.getId() );
		buf.append( ", " );
		buf.append( dto.getUserID() );
		buf.append( ", " );
		buf.append( dto.getText() );
		buf.append( ", " );
		buf.append( dto.getDate() );
		buf.append( ", " );
		buf.append( dto.getProcessed() );
		System.out.println( buf.toString() );
	}

}
